package com.kaibes.web.admin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kaibes.web.admin.AdminMenu;

@SuppressWarnings("serial")
public class AdminMenu implements Comparable<AdminMenu>, Serializable {
    
    private String key;
    private String parentKey;
    private String name;
    private String icon;
    private String href;
    private Integer sort;
    
    @JsonIgnore
    private AdminMenu parent;
    @JsonIgnore
    private List<AdminMenu> menuList = new ArrayList<>();
    
    @Override
    public int compareTo(AdminMenu o) {
        return sort-o.sort;
    }
    
    void setParent(AdminMenu parent) {
        this.parent = parent;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getParentKey() {
        return parentKey;
    }

    public void setParentKey(String parentKey) {
        this.parentKey = parentKey;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getHref() {
        return href;
    }

    public void setHref(String href) {
        this.href = href;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public List<AdminMenu> getMenuList() {
        return menuList;
    }

    public void setMenuList(List<AdminMenu> menuList) {
        this.menuList = menuList;
    }

    public AdminMenu getParent() {
        return parent;
    }
    
    @Override
    public boolean equals(Object obj) {
        return Objects.equals(key, ((AdminMenu)obj).key);
    }
}
